<?php require RCMS_Object_QuickConfig_QuickConfig::PATH_HEADER; ?>
<?php $this->headMeta()->appendName('keywords', 'Free shopping cart, Open source shopping cart, shopping cart, ecommerce solution'); ?>
<?php $this->headMeta()->appendName('description', $this->websiteUrl . ' Shopping Cart'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl .'system/js/php.js'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl .'system/js/shipping/shipping.js'); ?>
{$seotop}
<div id="seotoaster" class="cartview">
	<div id="startmsg" class="success" style="display: none; position: fixed">
		{%Updating your cart%}. {%Please wait%}...
	</div>
	<div id="companyinfo">
        <a href="<?php echo $this->websiteUrl; ?>">
            <img src="<?php echo str_replace('/small/', '/original/', $this->logoPath . $this->companyLogoName); ?>" alt="<?php echo $this->companyName; ?>" style="border:none;" />
        </a>
		<div>
            <p><?php echo $this->config['company']; ?><p>
            <p><?php echo $this->config['address'];
            if (!empty($this->config['address']) && !empty($this->config['address2'])) echo ', ';
            if (!empty($this->config['address2'])) echo $this->config['address2'];
            ?></p>
            <p><?php
            if (!empty($this->config['city'])) echo $this->config['city'];
            if (!empty($this->config['city']) && (!empty($this->config['state']) or !empty($this->config['zip']))) echo ', ';
            if (!empty($this->config['state'])) echo $this->config['state'];
            if (!empty($this->config['state']) && !empty($this->config['zip'])) echo ' ';
            if (!empty($this->config['zip'])) echo $this->config['zip'];
            ?></p>
            <p><?php if (!empty($this->config['country'])) echo $this->config['country']; ?></p>
            <p><?php echo $this->config['phone'];?></p>
            <p><a href="mailto:<?php echo $this->config['email']; ?>"><?php echo $this->config['email']; ?></a></p>
		</div>
		<h1 style="text-align:center;position:absolute;bottom:5px;right:15px;">{%Shopping cart overview%}</h1>
	</div>
    <div id="secure-note" >
        <img src="<?php echo $this->websiteUrl; ?>system/images/lock.png" alt="Secured" style="float:right; margin: 0 10px"/>
        {%Thanks to our state of the art shopping cart, your credit card information is safe. Our system never gain access to your credit card information.
        Instead, when you click  to finalize your purchase, we send your information securely from your computer directly to our payment processing gateway.%}
    </div>
    <?php $colnum = $this->config['show-price-ati'] == 0 ? 8 : 7; ?>
    <?php $k = floor(100/$colnum); ?>
	<div id="cartview-toplegend">
		<div style="width:<?php echo $k ;?>%;">{%Photo%}</div>
        <div style="width:<?php echo $k ;?>%;">{%Item Id%}</div>
		<div style="width:<?php echo 1.5*$k ;?>%;">{%Description%}</div>
        <div style="width:<?php echo $k ;?>%;">{%Quantity%}</div>
        <div style="width:<?php echo $k ;?>%;">{%Unit Price%}</div>
        <?php if (!isset($this->config['show-price-ati']) || $this->config['show-price-ati'] == 0) :?>
        <div style="width:<?php echo $k ;?>%;">{%Tax%}</div>
        <?php endif; ?>
        <div style="width:<?php echo $k ;?>%;">{%Price%}</div>
		<div style="width:<?php echo 0.5*$k ;?>%;">{%Remove%}</div>
	</div>
            
		<form action="javascript:;" id="cartview-itemsholder">
			<?php foreach($this->products as $key => $product): ?>
			  <div class="productitem" id="item-<?php echo $product['id'] . '-' . $key; ?>">
                    <div class="item-photo" style="width:<?php echo $k ;?>%"><img src="<?php echo $this->websiteUrl . $product['photo']; ?>" alt="<?php echo $product['name']; ?>"/></div>
					<div class="item-id" style="width:<?php echo $k ;?>%;"><?php echo $product['itemId']; ?></div>
                    <div class="item-name" style="width:<?php echo 1.5*$k ;?>%;text-align:left;"><?php echo substr($product['name'],0,50); ?>
						<?php if(isset($product['options'])): ?>
							<?php foreach($product['options'] as $optKey => $optionsData): ?>
								<?php if($optionsData != 'select ' . $optKey): echo $optKey . ': ' . $optionsData; endif;?>
								<input class="<?php echo $product['id'] . '-' . $key; ?> product-options" type="hidden" value="<?php echo $optKey . '=' . $optionsData; ?>" />
							<?php endforeach; ?>
						<?php endif; ?>
					</div>
                    <div class="item-count" style="width:<?php echo $k ;?>%;">
                        <input class="qty-item" type="number" min="0" data-start="<?php echo $product['count']; ?>" value="<?php echo $product['count']; ?>" />
                    </div>
                    <?php if (isset($this->config['show-price-ati']) && $this->config['show-price-ati'] == 1) :?>
                    <div class="item-price" style="width:<?php echo $k ;?>%;font-weight:bold;"><?php echo number_format(($product['price']+$this->taxPerItems[$product['id']]),2,'.','') ; ?></div>
                    <?php else: ?>
					<div class="item-price" style="width:<?php echo $k ;?>%;font-weight:bold;"><?php echo number_format($product['price'],2,'.',''); ?></div>
					<div class="item-tax" id="" style="width:<?php echo $k ;?>%;font-weight:bold;"><?php echo $this->taxPerItems[$product['id']]; ?></div>
					<?php endif; ?>
                    <div class="item-total" style="width:<?php echo $k ;?>%;font-weight:bold">
                        <?php if (isset($this->config['show-price-ati']) && $this->config['show-price-ati'] == 1) :?>
                        <?php echo number_format( (($product['price']+$this->taxPerItems[$product['id']])*$product['count']), 2, '.','') ; ?>
                        <?php else: ?>
                        <?php echo number_format( ($product['price']*$product['count']), 2, '.','') ; ?>
                        <?php endif; ?>
                    </div>
                    <div class="item-delchck" style="width:<?php echo 0.5*$k ;?>%;">
                        <a class="rem-item" href="javascript:;" ><img src="<?php echo $this->websiteUrl; ?>system/images/trash.png" alt="{%Remove%}"/></a>
                    </div>
                    <input type="hidden" class="item-id" value="<?php echo $product['id']; ?>" />
                    <input type="hidden" class="item-unit-price" value="<?php echo $product['price']; ?>" />
                    <input type="hidden" class="item-unix-tax" id="item-unix-tax-<?php echo $product['id']; ?>" value="<?php echo $this->taxPerItems[$product['id']]; ?>" />
				</div> 
                <?php if (isset($this->freebies[$product['id']])): ?>
                    <?php foreach ($this->freebies[$product['id']] as $freebie) :?>
                        <div class="productitem freebies parent-<?php echo $product['id'].'-'.$key; ?>">
                            <div class="item-photo" style="width:<?php echo $k ;?>%;"><img src="<?php echo $this->websiteUrl . $freebie['photo']; ?>" alt="<?php echo $freebie['name'];?>" /></div>
                            <div class="item-id" style="width:<?php echo $k ;?>%;"><?php echo $freebie['itemId']; ?></div>
                            <div class="item-name" style="width:<?php echo 1.5*$k ;?>%;text-align:left;"><?php echo $freebie['name'];?></div>
                            <div class="item-count" style="width:<?php echo $k ;?>%;font-weight: bold"><?php echo $freebie['count']; ?></div>
                            <div class="item-price" style="width:<?php echo $k ;?>%;font-weight: bold">{%FREE%}</div>
                            <?php if (!isset($this->config['show-price-ati']) || $this->config['show-price-ati'] == 0) :?>
                            <div class="item-tax" style="width:<?php echo $k ;?>%;"></div>
                            <?php endif; ?>
                            <div class="item-total" style="width:<?php echo $k ;?>%;font-weight: bold">{%FREE%}</div>
                            <div class="item-delchck" style="width:<?php echo 0.5*$k ;?>%;"></div>
                            <input type="hidden" class="item-unit-price" value="<?php echo $freebie['price']; ?>" />
                        </div>
                    <?php endforeach; ?>
                <?php endif; ?>
			<?php endforeach; ?>
		</form>

    <?php if ($this->allowShipping && count($this->products) > 0): ?>
    <div id="shipping-info">
        <div id="shipping-info-title" >
			<div id="shipping-info-title-default">
				<span>{%Enter your shipping address%}</span>
			</div>
			<div id="shipping-info-title-proccessed" style="display: none">
				<span>{%Your shipping address%}.</span>
				<input  type="button" id="edit-shipping" class="formsubmit" style="margin-left: 20px; width: auto;" value=" {%Edit Address or quantities%} "/>
			</div>
        </div>
        <form id="shipping-info-form" action="javascript:;">
            <div>
                <p><label>{%First Name%}: *</label> <input type="text" name="shipping-firstname" id="shipping-firstname" value="<?php echo $this->shippingData['firstname'];?>"></p>
                <p><label>{%Last Name%}:</label> <input type="text" name="shipping-lastname" id="shipping-lastname" value="<?php echo $this->shippingData['lastname'];?>"></p>
                <p><label>{%Company%}:</label> <input type="text" name="shipping-company" id="shipping-company" value="<?php echo $this->shippingData['company'];?>"></p>
                <p><label>{%E-mail%}:</label> <input type="text" name="shipping-email" id="shipping-email" value="<?php echo $this->shippingData['email'];?>"></p>
                <p><label>{%Shipping Address%} 1: *</label> <input type="text" name="shipping-address1" id="shipping-address1" value="<?php echo $this->shippingData['address1'];?>"></p>
                <p><label>{%Shipping Address%} 2:</label> <input type="text" name="shipping-address2" id="shipping-address2" value="<?php echo $this->shippingData['address2'];?>"></p>
            </div>
            <div>
                <p><label>{%Country%}: *</label>
                <?php echo $this->formSelect('shipping-country', null, null, RCMS_Object_QuickConfig_QuickConfig::$worldCountries); ?>
                </p>
                <p><label>{%City%}: *</label> <input type="text" name="shipping-city" id="shipping-city" value="<?php echo $this->shippingData['city'];?>"></p>
                <p><label>{%State%}:</label>
                <select id="shipping-state" name="shipping-state" <?php echo (empty($this->shippingData['state'])? 'disabled="true"' : ' ') ?> >
                    <option value="" />
                </select>
            </p>
            <p><label>{%ZIP Code%}: *</label><input type="text" name="shipping-zip" id="shipping-zip"  value="<?php echo $this->shippingData['zip'];?>"></p>
            
            <p><label>{%Phone%}:</label><input type="text" name="shipping-phone" id="shipping-phone"  value="<?php echo $this->shippingData['phone'];?>"></p>
            <p><label>{%Mobile%}:</label><input type="text" name="shipping-mobile" id="shipping-mobile"  value="<?php echo $this->shippingData['mobile'];?>"></p>
			<input type="hidden" id="shipping-service" name="shipping-service" value="<?php echo $this->shippingService; ?>" />
            </div>
			<div style="clear: both; width: 99%">
				<p><label>{%Shipping instructions%}:</label></p>
				<p style="vertical-align: middle; height: 40px;">
					<textarea style="width: 99%; height: 30px; <?php echo (empty($this->shippingData['instructions'])?'color: #7c7c7c':''); ?>" name="shipping-instructions" id="shipping-instructions"><?php echo (empty($this->shippingData['instructions'])?'':$this->shippingData['instructions']); ?></textarea>
				</p>
			</div>
            <?php if ($this->shippingGeneral['gifting'] == 'on') : ?>
            <div>
                <p><label>{%This order is a gift. (Gift orders will not ship with a receipt)%}</label><input type="checkbox" name="gift-order" id="gift-order"/></p>
                <textarea rows="3" name="gift-card-message" id="gift-cart-message" style="width:97%;" onfocus="if(this.value=='{%Enter Your Gift Card Message Here%}...'){this.value='';}" onblur="if(this.value==''){this.value='{%Enter Your Gift Card Message Here%}...';}">{%Enter Your Gift Card Message Here%}...</textarea>
            </div>
            <?php endif; ?>
            
        </form>
    </div><!--shipping info-->
    <?php endif; ?>
        
    <div id="totalprice">
        <div style="float:none;clear:both;width:100%;overflow:hidden;width:auto;white-space:nowrap;">
    	<button class="formsubmit" id="keepshopping" onclick="window.location.href='<?php echo $this->keepShoppingUrl; ?>';" style="float:left;">{%Keep shopping%}</button>
        <?php if ( count($this->products) > 0) : ?>
            <?php if ($this->allowShipping) : ?>
            <button class="formsubmit" id="checkout" onclick="proccessCheckout();" style="margin-left:20px;">{%Calculate shipping and checkout%}</button>
            <?php else :?>
            <button class="formsubmit" id="checkout" onclick="countTaxes();recountTotal();$('.cart-pay').show('slow');" style="margin-left:20px;">{%Checkout%}</button>
            <?php endif;?>
        <?php endif; ?><br />
        </div>
            <?php if (trim($this->shippingGeneral['notice'])!=''):?>
            <div style="float:left; clear: left; width: 500px">
                <?php echo $this->shippingGeneral['notice']; ?>
            </div>
            <?php endif; ?>
            <div>
                <?php if ( count($this->products) == 0 ): ?>
                    <span>{%There are no items in your cart%}.</span>
                <?php else : ?>
                    <?php if (isset($this->config['show-price-ati']) && $this->config['show-price-ati'] == 1) :?>
                        <span style="float:left; clear:left">{%Subtotal%}:</span><span style="float:right; margin:0px 5px"><?php echo $this->currency;?></span><span id="including-tax" style="float: right"><?php echo number_format(($this->total + $this->totalTax), 2, '.',''); ?></span><br/>
                        <span style="float:left; clear:left">{%Shipping%}:</span><span style="float:right; margin:0px 5px"><?php echo $this->currency;?></span><span id="shipping-value" style="float:right"><?php echo ($this->shipping && $this->total) ? $this->shipping : '0.00'; ?></span><br/>
                        <span style="float:left; clear:left">{%Total%}:</span><span style="float:right; margin:0px 5px"><?php echo $this->currency;?></span><span id="total-price-value" style="float:right"><?php echo ($this->totalPrice && $this->total) ? $this->totalPrice : '0.00'; ?></span><br/>
                        <span style="float:left; clear:left">{%Including Tax%}:</span><span style="float:right; margin:0px 5px"><?php echo $this->currency;?></span><span id="total-tax" style="float:right"><?php echo ($this->totalTax && $this->total) ? $this->totalTax : '0.00'; ?></span><br/>
                        <span style="float:left; clear:left">{%Total w/o Tax%}:</span><span style="float:right; margin:0px 5px"><?php echo $this->currency;?></span><span id="total-wo-tax" style="float:right"><?php echo number_format(($this->shipping + $this->total),2,'.','') ; ?> </span><br/>
                        <span id="sub-total" style="display: none"><?php echo ($this->total) ? number_format($this->total,2,'.','')  : '0.00'; ?></span>
                    <?php else :?>
                        <span style="float:left; clear:left">{%Subtotal%}:</span><?php if ($this->total):?><span style="float:right; margin:0px 5px"><?php echo $this->currency;?></span><?php endif; ?><span id="sub-total" style="float:right"><?php echo ($this->total) ? number_format($this->total,2,'.','')  : '0.00'; ?></span><br/>
                        <span style="float:left; clear:left">{%Total Tax%}:</span><span style="float:right; margin:0px 5px"><?php echo $this->currency;?></span><span id="total-tax" style="float:right"><?php echo ($this->totalTax && $this->total) ? $this->totalTax : '0.00'; ?></span><br/>
                        <span style="float:left; clear:left">{%Shipping%}:</span><span style="float:right; margin:0px 5px"><?php echo $this->currency;?></span><span id="shipping-value" style="float:right"><?php echo ($this->shipping && $this->total) ? $this->shipping : '0.00'; ?></span><br/>
                        <span style="float:left; clear:left">{%Total%}:</span><span style="float:right; margin:0px 5px"><?php echo $this->currency;?></span><span id="total-price-value" style="float:right"><?php echo ($this->totalPrice && $this->total) ? $this->totalPrice : '0.00'; ?></span><br/>
                    <?php endif ;?>

                <?php endif;?>
            </div>
            <?php if (isset($this->policyUrl)) : ?>
                <div style="float:left; clear: left; width: 500px; bottom:0px;">
                    <p>
                        {%Read%} {%our%} <a id="policy-url" href="<?php echo $this->policyUrl; ?>" title="{%Return &amp; Shipping Policy%}">{%Return &amp; Shipping Policy%}</a>
                    </p>
                </div>
            <?php endif; ?>
    </div>

<div style="padding-top:4px;"></div>
    <div class="cart-pay">
    	<div style="padding-top:1px;"></div>
        {$content:cartcontent}
        <?php if ($this->config['gateway'] == 'paypal') :?>
		<?php if (!empty($this->settingsPayPal['email'])) :?>
        <fieldset id="cart-settings-paypal-account" class="cart-settings" style="margin-top:15px;"><legend>{%Pay with PayPal%}</legend>
            <div style="float: left; width: 100%; text-align: center">
				<form action="https://www.paypal.com/cgi-bin/webscr" onclick="savePaypalDataCart('<?php echo $this->websiteUrl."sys/backend_shopping/saveuserdata/"; ?>');" target="_blank" method="post">
                <input type="hidden" name="cmd" value="_cart"/>
                <input type="hidden" name="upload" value="1"/>
                <input type="hidden" name="business" value="<?php echo $this->settingsPayPal['email']; ?>">
                <input type="hidden" name="lc" value="US">
				<input type="hidden" name="custom" value="cart">
                <div id="paypal-cart">
                <?php $counter = 0; foreach($this->products as $key => $product): ?>
                <?php $counter++ ;?>
                <input type="hidden" name="item_name_<?php echo $counter;?>" value="<?php echo $product['name'] ;?>" />
                <input type="hidden" name="item_number_<?php echo $counter;?>" value="<?php echo $product['itemId']; ?>">
                <input type="hidden" name="quantity_<?php echo $counter;?>" value="<?php echo $product['count'] ;?>" />
                <input type="hidden" name="amount_<?php echo $counter;?>" value="<?php echo $product['price'] ;?>" />
                <?php if (isset($this->freebies[$product['id']])) : ?>
                <?php foreach ($this->freebies[$product['id']] as $freebie) :?>
                <?php $counter++ ;?>
                <input type="hidden" name="item_name_<?php echo $counter;?>" value="<?php echo $freebie['name'] ;?>" />
                <input type="hidden" name="item_number_<?php echo $counter;?>" value="<?php echo $freebie['itemId']; ?>">
                <input type="hidden" name="quantity_<?php echo $counter;?>" value="<?php echo $freebie['count'] ;?>" />
                <input type="hidden" name="amount_<?php echo $counter;?>" value="<?php echo $freebie['price'] ;?>" />
                <?php endforeach; ?>
                <?php endif; ?>
                <?php endforeach; ?>
                </div>
                <input type="hidden" name="shipping_1" class="payment-gateway-shipping" value="<?php echo $this->shipping; ?>" />
                <input type="hidden" name="tax_cart" class="payment-gateway-total-tax" value="<?php echo ($this->totalTax) ? $this->totalTax : '0'; ?>">
                <input type="hidden" name="currency_code" value="<?php echo $this->config['currency']; ?>">
                <input type="hidden" name="button_subtype" value="products">
                <input type="hidden" name="notify_url" value="<?php echo $this->websiteUrl; ?>sys/backend_shopping/handlerpaypalaccount/">
                <input type="hidden" name="rm"  value="2">
                <input type="hidden" name="cancel_return" value="<?php echo $this->websiteUrl; ?>cart">
                <input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynow_LG.gif:NonHostedGuest">
                <input type="image" src="<?php echo $this->websiteUrl; ?>system/images/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal" style="padding:0;border:0;">
                <?php if ($this->allowShipping) : ?>
                <!--input type="hidden" name="no_shipping" value="2" /-->
                <input type="hidden" name="first_name" value="<?php echo $this->shippingData['firstname'];?>"/>
                <input type="hidden" name="last_name" value="<?php echo $this->shippingData['lastname'];?>"/>
                <input type="hidden" name="address1" value="<?php echo $this->shippingData['address1'];?>"/>
                <input type="hidden" name="address2" value="<?php echo $this->shippingData['address2'];?>"/>
                <input type="hidden" name="city" value="<?php echo $this->shippingData['city'];?>"/>
                <input type="hidden" name="state" value="<?php echo $this->shippingData['state'];?>"/>
                <input type="hidden" name="zip" value="<?php echo $this->shippingData['zip'];?>"/>
                <input type="hidden" name="country" value="<?php echo $this->shippingData['country'];?>"/>
                <?php endif ; ?>
             </form>
                <img src="<?php echo $this->websiteUrl; ?>system/images/cc-logos.png" alt="PayPal Logo"/>
            </div>

            <p style="float: left; text-align: center; width: 100%; font-size: 14px">
                {%Pay with your bank account, credit card or PayPal balance without sharing your financial information%}.
            </p>
        </fieldset>
		<?php endif; ?>
        <?php if (!empty($this->settingsPayPal['user']) && !empty($this->settingsPayPal['signature'])): ?>
        <div class="cart-pay-title">{%OR%}</div>
        <fieldset style="margin-top:15px;" id="cart-settings-credit-card" class="cart-settings"><legend>{%Credit Card%}</legend>
            <form action="javascript:;" name="paypal-creditcard" id="paypal-creditcard">
                <fieldset style="width:50%;float:left;margin-right:20px;">
                <p><label>{%First Name%}:</label> <input type="text" name="credit-card-firstname" id="credit-card-firstname"></p>
                <p><label>{%Last Name%}:</label> <input type="text" name="credit-card-lastname" id="credit-card-lastname"></p>
                <p><label>{%Payment Type%}:</label>
                    <select name="credit-card-type" id="credit-card-type">
                        <option value="Visa" selected="selected">Visa</option>
                        <option value="MasterCard">MasterCard</option>
                        <option value="Discover">Discover</option>
                        <option value="Amex">American Express</option>
                    </select>
                </p>
                <p><label>{%Credit Card Number%}:</label> <input type="text" name="credit-card-cardnumber" id="credit-card-cardnumber"></p>
                <p><label>{%Card Verification Number%}:</label> <input type="text" name="credit-card-verification-number" id="credit-card-verification-number"></p>
                <p><label>{%Expiration Date%}:</label>
                    <select name="credit-card-expiration-date-year" id="credit-card-expiration-date-year" style="width:100px;margin-left:5px;">
                        <?php $currentYear = date('Y'); ?>
                        <?php for ($y=$currentYear; $y<=$currentYear+10; $y++): ?>
                        <option value="<?php echo $y; ?>"><?php echo $y; ?></option>
                        <?php endfor; ?>
                    </select>
                       <select name="credit-card-expiration-date-month" id="credit-card-expiration-date-month" style="width:50px;">
                        <?php for ($m=1; $m<=12; $m++) : ?>
                        <option value="<?php echo $m; ?>"><?php echo $m; ?></option>
                        <?php endfor; ?>
                    </select>
                </p>
                <p><label>{%E-mail%}:</label> <input type="text" name="credit-card-email" id="credit-card-email"></p>
                </fieldset>
				<fieldset>
                <p><label>{%Billing Address%} 1:</label> <input type="text" name="credit-card-billing-address1" id="credit-card-billing-address1"></p>
                <p><label>{%Billing Address%} 2:</label> <input type="text" name="credit-card-billing-address2" id="credit-card-billing-address2"></p>
                <p><label>{%Country%}:</label>
                    <?php echo $this->formSelect('credit-card-country', null, null, RCMS_Object_QuickConfig_QuickConfig::$worldCountries); ?>
                </p>
                <p><label>{%City%}:</label> <input type="text" name="credit-card-city" id="credit-card-city"></p>
                <p><label>{%State%}:</label>
                    <select id="credit-card-state" name="credit-card-state">
                        <option value="" />
                    </select>
                </p>
                <p><label>{%ZIP Code%}:</label><input type="text" name="credit-card-zip" id="credit-card-zip"></p>
                <p><label>{%Phone%}:</label><input type="text" name="credit-card-phone" id="credit-card-phone"></p>
				   <input type="hidden" name="credit-card-amt" id="credit-card-amt" class="payment-gateway-total" value="<?php echo $this->total; ?>" />
                   <input type="hidden" name="credit-card-shipping" id="credit-card-shipping" class="payment-gateway-shipping" value="<?php echo $this->shipping; ?>" />
                   <input type="hidden" name="credit-card-desc" id="credit-card-desc" value="<?php echo $paypalDescriptionProducts; ?>" />
                   <input type="hidden" name="credit-card-currency-code" id="credit-card-currency-code" value="<?php echo $this->config['currency']; ?>" />
                   <input type="hidden" name="credit-card-tax" id="credit-card-tax" class="payment-gateway-total-tax" value="<?php echo ($this->totalTax) ?  $this->totalTax : '0'; ?>" />
                </fieldset>
                <img style="float:left"src="<?php echo $this->websiteUrl; ?>system/images/paypal.png" alt="PayPal Logo"/>
                <?php if ($this->allowShipping) : ?>
                <p align="right" style="float:right;clear:right;margin:10px 15px 0px 0px;"><input type="checkbox" class="toggle-shipping" id="shipping-for-cc" style="margin: 2px 5px;"/><span>{%Use same address as shipping%}</span></p>
                <?php endif; ?>
                <p align="right" style="float:right;clear:right;margin:10px 15px 0px 0px;"><input type="button" class="formsubmit" style="padding-left:15px;padding-right:15px;" name="credit-card-paynow" id="credit-card-paynow" value="{%Pay Now%}"  onclick="payCreditCart();"></p>
            </form>
            
        </fieldset>

        <?php endif; ?>
        <?php endif; ?>
        <?php if ($this->config['quote']): ?>
        <div class="cart-pay-title">{%OR%}</div>

        <fieldset id="cart-settings-quote" class="cart-settings"><legend>{%Get a no obligation quote today%}</legend>
            <form action="javascript:;" name="form_quote" id="form_quote">
                <fieldset style="width:50%;float:left;margin-right:20px;">
                    <p><label>{%First Name%}:*</label><input type="text" name="cart-quote-firstname" id="cart-quote-firstname"></p>
                    <p><label>{%Last Name%}:</label><input type="text" name="cart-quote-lastname" id="cart-quote-lastname"></p>
                    <p><label>{%Company%}:</label><input type="text" name="cart-quote-company" id="cart-quote-company"></p>
                    <p><label>{%E-mail%}:*</label><input type="text" name="cart-quote-email" id="cart-quote-email"></p>
                    <p><label>{%Phone%}:</label><input type="text" name="cart-quote-phone" id="cart-quote-phone"></p>
                    <p><label>{%Address%} 1:</label><input type="text" name="cart-quote-address1" id="cart-quote-address1"></p>
                    <p><label>{%Address%} 2:</label><input type="text" name="cart-quote-address2" id="cart-quote-address2"></p></fieldset><fieldset>
                    <p><label>{%Country%}:</label>
                        <?php echo $this->formSelect('cart-quote-country', null, null, RCMS_Object_QuickConfig_QuickConfig::$worldCountries); ?>
                    </p>
                    <p><label>{%City%}:</label><input type="text" name="cart-quote-city" id="cart-quote-city"></p>
                    <p><label>{%State%}:</label>
                        <select id="cart-quote-state" name="cart-quote-state">
                            <option value="" />
                        </select>
                    </p>
                    <p><label>{%Zip%}:</label><input type="text" name="cart-quote-zip" id="cart-quote-zip"></p>

                    <p style="height:80px;"><label>{%Comments%}:</label><textarea name="cart-quote-comments" id="cart-quote-comments" cols="5" rows="3" style="width:200px;"></textarea></p>
                       </fieldset>
                <?php if ($this->allowShipping) : ?>
                <p align="right" style="margin:10px 15px 0px 0px;"><input type="checkbox" class="toggle-shipping" id="shipping-for-quote" style="margin: 2px 5px;"/><span>{%Use same address as shipping%}</span></p>
                <?php endif;?>
                <p align="right"><input type="button" class="formsubmit" name="cart-quote-quoteme" id="cart-quote-quoteme" value="{%Quote Me%}" style="padding-left:15px;padding-right:15px;" onclick="saveQuote();"></p>
            </form>
        </fieldset>
        <?php endif; ?>
        <br />
    </div>
<?php if (isset($this->config['legal-info']) && !empty($this->config['legal-info'])):?>
<span class="seofooter">
<?php echo $this->config['legal-info']; ?> 
</span>
<?php endif;?>
<span class="seofooter">
<a title="{%Free Shopping Cart%}" target="_blank" href="http://www.seotoaster.com/">{%Free Shopping Cart%}</a> {%by SEOTOASTER%}</span>
</div>

<script type="text/javascript">

    $(document).ready(function(){

		<?php if ($this->config['use_https']): ?>
		// replace protocol for cart checkout to https if SSL use.
		if (window.location.protocol == 'https:' && $('#hid-main-wsurl').val().indexOf('http:')!=-1) { //
			$('#hid-main-wsurl').val($('#hid-main-wsurl').val().replace('http:', 'https:'));
		}
		<?php endif; ?>
        //copying data from shipping address
        $(".toggle-shipping").click(function(){
           if ($(this).attr('checked') == true) {
               copyShippingData($(this).parent().parent().attr('name'));
               return;
           }
        })

        // handler for changing country
        $('select[id$="-country"]').change(function(){
            var stateField = $(this).closest('form').find('select[id$="-state"]')
            
            if ($(this).val() == 'US' || $(this).val() == 'CA'){
                  stateField.removeAttr('disabled')
                  stateField.html(loadStates($(this).val()))
            } else {
                  stateField.attr('disabled',true)
                  stateField.html('')
            }

        });

		// load session based value for coutry, state in all
        <?php if (isset($this->location)): ?>
        $('select[id$="-country"]').each(function(){
			$(this).val('<?php echo $this->location['country'];?>').change();
		});
		<?php if (!empty($this->location['state'])) :?>
        $('select[id$="-state"]').each(function(){
			$(this).val('<?php echo $this->location['state'];?>');
		});
        <?php endif;?>
        <?php endif; ?>
        
        $("#edit-shipping").click(function(){
			$('#shipping-info-title-proccessed').hide();
			$('#current-shipping-address').remove();
            $('#shipping-info-title-default').show();
            $('#shipping-info-form').show();
            $('.cart-pay').hide();
            $('#checkout').show();
            $('#shipping-for-cc').attr('checked',false);
            $('#shipping-for-quote').attr('checked',false);
            $('input.qty-item').removeAttr('disabled');
            $('a.rem-item').show();           
        });

        // removing items from cart
        $('.rem-item').click(function(){
            var websiteurl = $('#hid-main-wsurl').val()
            var $itemHolder = $(this).closest('div.productitem');
            var parentKey = $itemHolder.attr('id').replace('item','parent');
            var itemId = $itemHolder.find('input.item-id:hidden').val();
            var itemOptions = []
            $itemHolder.find('input:hidden').each(function(){
                if ($(this).hasClass('product-options')){
                    itemOptions.push($(this).val())
                }
            });
            data = { toremove: itemId, remOptions: json_encode(itemOptions) };

            $('#startmsg').ajaxStart(function(){
                $(this).html('{%Updating your cart%}. {%Please wait%}...').show();
            });

            $.ajax({
                async: false,
                url: websiteurl + 'sys/backend_shopping/recount',
                type: 'POST',
                data: data,
                dataType: 'json',
                success: function(responce){
                    if (responce){
                        if (responce.totalPrice > 0){
                            $('.'+parentKey).remove();
                            $itemHolder.fadeOut().remove();
                            $('#sub-total').text(responce.totalPrice);
                            countTaxes();
                            recountTotal();
                            $('#startmsg').text('{%Done%}').hide();
                        } else {
                            top.location.reload();
                        }
                        cartToPayPal();
                    }
                },
                context: $(this)
            });
        });

        // changing quantity for item
        $('input.qty-item').change(function(){
            var websiteurl = $('#hid-main-wsurl').val();
            
            var startVal = $(this).attr('data-start'); // $(this).data('start') for JQ >= 1.4.3
            var newQty = $(this).val();
            

            if (/\d{1,10}/.test(newQty)){
                var $itemHolder = $(this).closest('div.productitem');
                var parentKey = $itemHolder.attr('id').replace('item','parent');
                var itemId = $itemHolder.find('input.item-id:hidden').val();
                var itemPrice = parseFloat($itemHolder.find('input.item-unit-price:hidden').val());
                var itemOptions = [];
                $itemHolder.find('input:hidden').each(function(){
                    if ($(this).hasClass('product-options')){
                        itemOptions.push($(this).val());
                    }
                });

                $('#startmsg').ajaxStart(function(){
                    $(this).html('{%Updating your cart%}. {%Please wait%}...').show();
                });
                
                $.ajax({
                    url: websiteurl + 'sys/backend_shopping/recount',
                    type: 'POST',
                    data: {torecount: json_encode({id: itemId, qty: newQty }), options: json_encode(itemOptions)},
                    dataType: 'json',
                    success: function(responce){
                        if (responce) {
                            $('#sub-total').text(responce.totalPrice.toFixed(2));
                            if (newQty != '0'){
                                <?php if (isset($this->config['show-price-ati']) && $this->config['show-price-ati'] == 1) :?>
                                var itemTax = parseFloat($itemHolder.find('input.item-unix-tax:hidden').val());
                                itemTax = isNaN(itemTax)?0:itemTax;
                                var itemTotal = (itemPrice+itemTax)*newQty;
                                <?php else: ?>
                                var itemTotal = itemPrice*newQty;
                                <?php endif; ?>

                                $itemHolder.find('input.qty-item').attr('data-start', newQty);
                                $itemHolder.find('div.item-total').text(itemTotal.toFixed(2));
                                $('.'+parentKey).find('div.item-count').text(newQty);
                            } else {
                                $('.'+parentKey).remove();
                                $itemHolder.fadeOut().remove();
                            }
                            $('#cartview-itemsholder').queue(countTaxes());
                            $('#cartview-itemsholder').queue(recountTotal());
                            $('#cartview-itemsholder').queue(cartToPayPal());
                            $('#startmsg').text('{%Done%}').fadeOut('slow');
                        }
                    }
                    //, context: $(this)
                });
            } else {
                $(this).focus().val(startVal)
            }
        });

        $('input.item-unix-tax').bind('updatePrices', function(event, param){
            var $itemHolder = $(this).closest('div.productitem');
            var itemPrice   = parseFloat($itemHolder.find('input.item-unit-price:hidden').val());
            var itemTax     = parseFloat($(this).val());
            var qty         = parseFloat($itemHolder.find('input.qty-item').val());
            var newItemPrice = itemPrice+itemTax;
            var newItemTotal = newItemPrice*qty;
            $itemHolder.find('div.item-price').text(newItemPrice.toFixed(2));
            $itemHolder.find('div.item-total').text(newItemTotal.toFixed(2));
        });

		$('#policy-url').click(function(event){
			event.preventDefault();
			var newWidth = ($(window).width()*0.6).toFixed(0)
			var nw=window.open($(this).attr('href'), $(this).attr('alt'), 'width='+newWidth+',height=480,location=no,status=no,toolbar=no,menubar=no');
			nw.focus();
		});

    // end of $(document).ready()
    });

    $('.productitem:odd').css('background', '#FFFFEE');
    
    function saveQuote()
    {
		var websiteurl = $('#hid-main-wsurl').val();
        var regEmail = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})$/;
        var name = $('#cart-quote-firstname').val() + ' ' + $('#cart-quote-lastname').val();
        var email = $('#cart-quote-email').val();
        name = name.replace(/^\s+/g,''); name = name.replace(/\s+$/g,'');
        if(email == '' || !email.match(regEmail) || name == '') {
            $('#cart-quote-email').css({backgroundColor: 'red' }).focus();
            return false;
        } else {
            $('#cart-quote-email').css({backgroundColor: 'white' });
        }
        $.ajax({
            url : websiteurl+'sys/backend_shopping/quoteme/',
            type : 'post',
            dataType : 'json',
            data : {
                name : name,
                email : email,
                company : $('#cart-quote-company').val(),
                country : $('#cart-quote-country').val(),
                state : null!==$('#cart-quote-state').val()?$('#cart-quote-state').val():'',
                city : $('#cart-quote-city').val(),
                zip : $('#cart-quote-zip').val(),
                address1 : $('#cart-quote-address1').val(),
                address2 : $('#cart-quote-address2').val(),
                phone : $('#cart-quote-phone').val(),
                comments : $('#cart-quote-comments').val()
            },
            beforeSend : function() {
                $('#startmsg').html('{%Transmitting your quote request now%}...');
                $('#startmsg').show();
            },
            complete : function() {
                window.setTimeout('$("#startmsg").hide();', 5000);
            },
            success : function(result) {
                if (result.done) {
                    $('#startmsg').html('{%Your quote request was transmitted.%}');
                } else {
                    $('#startmsg').html('{%Your quote request is fail.%}');
                }
                if (undefined!==result.redirect) {
                    window.location.href=result.redirect
                }
            }
        });
    }
    
    function payCreditCart()
    {
		var websiteurl = $('#hid-main-wsurl').val();
		$('#credit-card-paynow').attr('disabled', true).fadeOut();
        $.ajax({
            url : websiteurl+'sys/backend_shopping/handlerpaypalcreditcard/',
            type : 'post',
            dataType : 'json',
            data : {
                firstname : $('#credit-card-firstname').val(),
                lastname : $('#credit-card-lastname').val(),
                type : $('#credit-card-type').val(),
                cardnumber : $('#credit-card-cardnumber').val(),
                verification_number : $('#credit-card-verification-number').val(),
                expiration_date_year : $('#credit-card-expiration-date-year').val(),
                expiration_date_month : $('#credit-card-expiration-date-month').val(),
                email: $('#credit-card-email').val(),
                billing_address1 : $('#credit-card-billing-address1').val(),
                billing_address2 : $('#credit-card-billing-address2').val(),
                city : $('#credit-card-city').val(),
                country : $('#credit-card-country').val(),
                state : $('#credit-card-state').val(),
                zip : $('#credit-card-zip').val(),
                phone : $('#credit-card-phone').val(),
                amt : $('#credit-card-amt').val(),
                desc : $('#credit-card-desc').val(),
                currency_code : $('#credit-card-currency-code').val(),
                tax : $('#credit-card-tax').val(),
                shipping : $('#credit-card-shipping').val()
            },
            beforeSend : function() {
                $('#startmsg').html('{%Process paying, please wait%}...').show().unbind();
            },
            complete : function() {
				$('#startmsg:hidden').show();
            },
            success : function(result) {
                if (result.done == true) {
                    $('#startmsg').css({backgroundColor:'green'});
                    $('#startmsg').html('{%Thank you for your purchase at%} <?php echo $this->websiteUrl; ?>. {%Feel free to contact us at%} <?php echo $this->config['phone'];?> {%should you have any question%}. {%You will be redirected to the homepage in a few seconds%}.');
                    window.setTimeout('$("#startmsg").hide(0, function() {window.location="<?php echo $this->websiteUrl; ?>" });', 3000);
                }
				else {
					if(result.state) {
						$('#startmsg').css({backgroundColor:'red'}).html('{%There was no activity for a while. You will be redirected to the homepage in a few seconds.%}');
						window.setTimeout('$("#startmsg").hide(0, function() {window.location="<?php echo $this->websiteUrl; ?>" });', 3000);
					}
					else{
					$('#credit-card-paynow').removeAttr('disabled').fadeIn();
                    $('#startmsg').css({backgroundColor:'red'})
                        .html('{%Sorry, your payment has failed, please double check your credit card information. If this error persists, please contact us.%}')
                        .one({
                            'click': function(){$(this).hide().css({backgroundColor:'olive'}).html('')}
                        })
					}
				}
            }
        });
    }

    function recountTotal(){
        var subTotal = (!isNaN($('#sub-total').text()) ? Number($('#sub-total').text()) : 0);
        var totalTax = (!isNaN($('#total-tax').text()) ? Number($('#total-tax').text()) : 0);
        var shipping = (!isNaN($('#shipping-value').text()) ? Number($('#shipping-value').text()) : 0);
        var total = subTotal + totalTax + shipping;
        
        <?php if (isset($this->config['show-price-ati']) && $this->config['show-price-ati'] == 1) :?>
        var incTaxes = subTotal + totalTax;
        var woTaxes = total - totalTax;
        $('#including-tax').text(incTaxes.toFixed(2));
        $('#total-wo-tax').text(woTaxes.toFixed(2))
        <?php endif;?>
        $('#total-price-value').text(total.toFixed(2));
        $('.payment-gateway-total').val(total.toFixed(2));
		if ($('#paypal-cart').size()){
			cartToPayPal();
		}
    }

    function countTaxes(){
        var urlwebsite = $('#hid-main-wsurl').val();

        var userCountry = $('#shipping-country').val();
        var userState   = $('#shipping-state').val();
        
        if (userCountry == '') {
            return false;   
        }

        $.ajax({
            async: false,
            type: 'POST',
            dataType: 'json',
            url: urlwebsite +'sys/backend_shopping/counttax/',
            data: ({
                userCountry: userCountry,
                userState: userState
            }),
            success: function(responce){
                $('#total-tax').text(responce.totaltax)
                $('.payment-gateway-total-tax').val(responce.totaltax)
                if (responce.totaltax){
                    for (var productId in responce.taxPerItem){
                        $('div[id^=item-'+productId+']').find('.item-tax').text(responce.taxPerItem[productId]);
                        <?php if (isset($this->config['show-price-ati']) && $this->config['show-price-ati'] == 1) :?>
                        $('input#item-unix-tax-'+productId).val(responce.taxPerItem[productId]).trigger('updatePrices', '');
                        <?php endif; ?>
                    }
                } else {
                    $('div[id^=item]').find('.item-tax').text('0')
                }
            }
        });
    };
    function loadStates(country) {
        var str = '';

        switch (country) {
            case 'US':
                var states = <?php echo json_encode(RCMS_Object_QuickConfig_QuickConfig::$stateListUSA); ?> ;
                break;
            case 'CA':
                var states = <?php echo json_encode(RCMS_Object_QuickConfig_QuickConfig::$stateListCanada); ?> ;
                break;
            default:
                var states = {}
                break;
        }
        for (var state in states){
            str += '<option value="'+state+'">'+states[state]+'</option>'
        }
        return str;
    }


    function cartToPayPal (){
        var counter = 0;
        $('#paypal-cart').html('');
        $('.productitem').each (function(){
           counter++;
           var product = {
               item_name   : $(this).find('div.item-name').text(),
               item_number : $(this).find('div.item-id').text(),
               amount      : $(this).find('input.item-unit-price').val(),
               quantity    : $(this).find('input.qty-item').size() ? $(this).find('input.qty-item').val() : $(this).find('div.item-count').text() 
           };
           var itemHtml = '';
           for (var value in product){
               itemHtml += '<input type="hidden" name="'+value+'_'+counter+'" value="'+product[value]+'" />'
           }
           $('#paypal-cart').append(itemHtml);
        });
    }

    function proccessCheckout(){
	<?php if (isset($this->config['deny-int-payment']) && $this->config['deny-int-payment'] == 1 ) :?>
		if ('<?php echo $this->config['country']; ?>' != $('#shipping-country').val()) {
			$('.cart-pay').children(':not(#cart-settings-quote)').hide();
		} else {
			$('.cart-pay').children().show();
		}
	<?php endif;?>
        $('#cartview-itemsholder').queue('pc',validateShippingForm());
        $('#cartview-itemsholder').queue('pc',countTaxes());
        $('#cartview-itemsholder').queue('pc',recountTotal());
        $('#cartview-itemsholder').queue('pc');
    }

	function savePaypalDataCart(urlAction) {
    $.ajax({
        type: "POST",
        url: urlAction,
        dataType: "json",
        async:false,
        success: function(msg){
            $("[name=custom]").val(msg['reference']);
        },
        error: function(msgErr){

        }
    });
}
</script>
{$seobottom}
